﻿@model MvcCmsForum.Models.ViewData.ForumModel
@{
    ViewBag.Title = ViewData["PageTitle"];
    Layout = "~/RazorThemes/Default/Views/Shared/_Layout.cshtml";
}
@section HtmlHead{
<style type="text/css">
    label.error
    {
        float: none;
        color: red;
        padding-left: .5em;
        vertical-align: top;
    }
</style>
<link href="@Url.Content("/RazorThemes/" + Model._CurrentPortal.SkinName + "/css/Forum.css")" rel="stylesheet" type="text/css" />
}
<div>
    <div class="spacer_top">
    </div>
    <div id="thecontent" class="thecontent">
        <h2>
            <a href="/forums">Forums Home</a></h2>
        <h2>@Html.Encode(Model._Forum.Title) Forum</h2>
        @Html.ActionLink("Create A Post For This Forum", "CreatePost", new { forumId = Model._Forum.ForumID }, new { @class = "post-button" })
        <span class="field-validation-error">&nbsp; @ViewData["message"].ToString() </span>
        @if (Model._Posts.Count() == 0)
        {
            <p>
                There are no posts in this forum yet, you can be the first.</p>
        }
        else
        { 
            <div id="posts">
                @foreach (var post in Model._Posts)
                {
                    <div id="post-@post.PostID " class="post">
                        @if (User.IsInRole("Editor"))
                        {
                            <div class="admin">
                                @if (!post.Closed)
                                {
                                    <a class="close" meta:id="@post.PostID " href="#close">Close</a><text>&nbsp;|&nbsp;</text>
                                }
                                <a class="remove" meta:id="@post.PostID " href="#remove">Remove</a>
                            </div>
                        }
                        <div class="stats">
                            <div class="votes stat">
                                <strong>@post.VoteCount </strong><small>votes</small></div>
                            <div class="replies stat">
                                <strong>@post.ReplyCount </strong><small>replies</small></div>
                            <div class="views stat">
                                <strong>@post.ViewCount </strong><small>views</small></div>
                        </div>
                        <h3>
                            <a href="/forums/forum-@Html.Encode(post.Forum.Path)/@Html.Encode(post.Path)">@Html.Encode(post.Title)
                            </a>-@post.ThreadUser.UserName.ToProfileLink()
                            @if (post.Closed)
                            {
                                <text>[closed]</text>
                            }
                        </h3>
                        <div class="posted-last">
                            <span class="posted-at">last post - @post.LastPostDate.ToUtcTimeSinceString() ago</span>
                            <span class="posted-by">by
                                <img alt="avatar" src="@post.LastPostByAvatarUrl" />
                                @post.ReplyUser.UserName.ToProfileLink() </span>
                        </div>
                    </div>
            <hr />
                }
            </div>
        @Html.Partial("ControlsForum/ForumPager", Model._Posts)
        }
    </div>
</div>
@section SideBar{
@Html.Partial("ControlsForum/AdminSidebar")
}
@section ScriptContent{
<script type="text/javascript">
    LoadRecentPosts();
</script>
@if (User.IsInRole("Admin"))
{
    <script src="@Url.Content("/Areas/MvcCmsForum/scripts/manage-forums.js")" type="text/javascript"></script>
}
}
